<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<div class="aui-gutter-column-md">
    <h2>{{'protection_basic_config_label' | i18n}}</h2>
</div>

<div class="aui-gutter-column-md">
    <lv-group lvGutter="20px" class="padding-10" *ngIf="!isSearchRestore">
        <span class="aui-text-label">{{
            'protection_selected_copy_label' | i18n
            }}</span>
        <span>{{
            rowCopy.display_timestamp | date: 'yyyy-MM-dd HH:mm:ss'
            }}</span>
    </lv-group>
    <lv-group lvGutter="20px" class="padding-10" *ngIf="isSearchRestore">
        <span class="aui-text-label" style="width:90px">{{
            'protection_selected_file_label' | i18n
            }}</span>
        <span lv-overflow>{{ rowCopy.searchRestorePath | nil }}</span>
    </lv-group>
</div>

<ng-container *ngIf="childResType === dataMap.Resource_Type.ObjectSet.value">
    <aui-object-restore [rowCopy]="rowCopy" [childResType]="childResType" [restoreType]="restoreType"
        (onStatusChange)="disableBtn()"></aui-object-restore>
</ng-container>

<div class="content" *ngIf="!isSearchRestore">
    <h2>{{'explore_object_need_restore_label' | i18n}}</h2>
    <lv-alert *ngIf="incrementFileEmptyTips" lvType="info" [lvClosable]="false" class="list-view-mgt">
        {{'protection_restore_object_set_incremental_empty_file_tip_label'|i18n}}
    </lv-alert>
    <ng-container *ngTemplateOutlet="selectTableTpl">
    </ng-container>
</div>

<ng-template #selectTableTpl>
    <!-- 提供手动输入路径 -->
    <lv-alert lvType="info" class="mgt-8">
        {{'protection_manual_path_tip_label' | i18n}}
    </lv-alert>
    <lv-form class="aui-gutter-column-md">
        <lv-form-item>
            <lv-form-label>
                {{'protection_path_mode_label' | i18n}}
            </lv-form-label>
            <lv-form-control>
                <lv-radio-group [(ngModel)]="pathMode" [lvGroupName]="'group'" (ngModelChange)="pathModeChange()">
                    <lv-group [lvGutter]="'20px'">
                        <lv-radio [lvValue]="modeMap.fromTree">
                            {{ 'protection_path_from_tree_label' | i18n }}
                        </lv-radio>
                        <lv-radio [lvValue]="modeMap.fromTag">
                            {{ 'protection_path_from_input_label' | i18n }}
                        </lv-radio>
                    </lv-group>
                </lv-radio-group>
            </lv-form-control>
        </lv-form-item>
        <lv-form-item *ngIf="pathMode === modeMap.fromTag">
            <lv-form-label lvRequired>
                {{'protection_path_from_input_title_label' | i18n}}
                <i lv-icon="aui-icon-help" lv-tooltip="{{'protection_path_placeholder_tip_label' | i18n}}"
                    lvColorState='true'></i>
            </lv-form-label>
            <lv-form-control>
                <aui-manual-input-path [rowCopy]="rowCopy"
                    (pathChange)="inputPathChange($event)"></aui-manual-input-path>
            </lv-form-control>
        </lv-form-item>
    </lv-form>
    <ng-container *ngIf="pathMode === modeMap.fromTree">
        <lv-group class="upper-group bread-limit">
            <lv-breadcrumb [lvItems]="items" [lvSeparator]="'/'" class="bread"></lv-breadcrumb>
            <lv-search class="search-width" [(ngModel)]="name" (lvSearch)="searchObjectName($event)" [lvFocus]="true"
                [lvPlaceHolder]="'explore_object_file_level_search_tip_label' | i18n"></lv-search>
        </lv-group>
        <lv-datatable [lvData]="currentFileData" #lvTable [lvScroll]="{ y: '420px' }" lvSize="small"
            lvCompareWith="rootPath" lvSelectionMode="multiple" [lvSelection]="selectionData" [lvPaginator]="pageA"
            (lvSelectionChange)="selectionChange($event, 'headSelect')" lvResize lvAsync>
            <thead>
                <tr>
                    <th lvShowCheckbox width="64px" [lvRowsData]="lvTable.renderData"></th>
                    <th>{{'common_name_label' | i18n}}</th>
                    <th>{{'common_size_label' | i18n}}</th>
                    <th>{{'protection_last_modifyed_label' | i18n}}</th>
                </tr>
            </thead>
            <tbody>
                <tr *ngFor="let item of lvTable.renderData; trackBy:trackByRootPath">
                    <td width="64px">
                        <label lv-checkbox [lvIndeterminate]="item.isHalfSelected" [(ngModel)]="item.selected"
                            (ngModelChange)="checkChange($event, item)" style="margin-top:4px"></label>
                    </td>
                    <td>
                        <lv-group lvGutter="8px" (click)="getChildren(item)">
                            <i lv-icon="{{ item.icon }}" [lvColorState]="true"></i>
                            <span lv-overflow style="width:200px"
                                [ngClass]="{'aui-link': item.type !== restoreFileType.File}">{{item?.name}}</span>
                        </lv-group>
                    </td>
                    <td>
                        <span *ngIf="item.type === restoreFileType.File">{{
                            item.size
                            | capacityCalculateLabel: '1.1-3':unitconst.BYTE:true
                            }}</span>
                    </td>
                    <td>
                        <span *ngIf="item.type === restoreFileType.File">{{item?.modifyTime | nil}}</span>
                    </td>
                </tr>
            </tbody>
        </lv-datatable>
        <lv-paginator #pageA [lvPageSize]="pageSize * 10" [lvTotal]="total" [lvPageIndex]="pageIndex"
            (lvPageChange)="pageChange($event)" [lvShowPageSizeOptions]="false" [lvPageSizeOptions]="pageSizeOptions">
        </lv-paginator>
    </ng-container>
</ng-template>